package com.icez.base_compose_framework.util

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory

/**
 * ViewModel 工具类
 * @author icez
 */
object BViewModelUtil {

    /**
     * 创建 ViewModelProvider.Factory
     */
    inline fun <reified VM:ViewModel> viewModelProviderFactoryOf(crossinline create: ()-> VM):ViewModelProvider.Factory = viewModelFactory {
        initializer {
            create()
        }
    }
}